package 策略模式.three;

/**
 * 所有鸭子的超类
 * @author xuanjian
 * 策略模式
 */
public abstract class Duck {

	FlyBehavior flyBehavior;
	QuackBehavior quackBehavior;
	
	public FlyBehavior getFlyBehavior() {
		return flyBehavior;
	}

	public void setFlyBehavior(FlyBehavior flyBehavior) {
		this.flyBehavior = flyBehavior;
	}

	public QuackBehavior getQuackBehavior() {
		return quackBehavior;
	}

	public void setQuackBehavior(QuackBehavior quackBehavior) {
		this.quackBehavior = quackBehavior;
	}

	public void swim() {
		System.out.println("游泳：所有鸭子都会游泳。");
	}
	
	public void performQuack(){
		quackBehavior.quack();
	}
	
	public void performFly(){
		flyBehavior.fly();
	}
	
	abstract void display();//鸭子外观不一样
	
	abstract void type();//鸭子种类

	public void test(){
		System.out.println("--------------------");
		type();
		display();
		swim();
		performFly();
		performQuack();
		System.out.println("--------------------");
	}
}
